﻿CREATE TABLE [dbo].[FaresSetup] (
    [PrimaryKey]                     SMALLINT        CONSTRAINT [DF_FaresSetup_PrimaryKey] DEFAULT ((0)) NOT NULL,
    [CodUnitate]                     SMALLINT        CONSTRAINT [DF_FaresSetup_CodUnitate] DEFAULT ((0)) NOT NULL,
    [FolosesteAdresa]                BIT             CONSTRAINT [DF_FaresSetup_FolosesteAdresa] DEFAULT ((1)) NOT NULL,
    [GolesteInainteImport]           BIT             CONSTRAINT [DF_FaresSetup_GolesteInainteImport] DEFAULT ((0)) NOT NULL,
    [ParteneriProprii]               BIT             CONSTRAINT [DF_FaresSetup_ParteneriProprii] DEFAULT ((0)) NOT NULL,
    [IDSerie]                        NVARCHAR (20)   CONSTRAINT [DF_FaresSetup_IDSerie] DEFAULT ('') NOT NULL,
    [AnCurent]                       SMALLINT        CONSTRAINT [DF_FaresSetup_AnCurent] DEFAULT ((0)) NOT NULL,
    [LunaCurenta]                    SMALLINT        CONSTRAINT [DF_FaresSetup_LunaCurenta] DEFAULT ((0)) NOT NULL,
    [ContArticolImplicit]            [dbo].[TipCont] NULL,
    [ContCheltuialaArticolImplicit]  [dbo].[TipCont] NULL,
    [CotaTVAImplicita]               DECIMAL (5, 2)  CONSTRAINT [DF_FaresSetup_CotaTVAImplicita] DEFAULT ((0)) NOT NULL,
    [ComenziFaraTVA]                 BIT             CONSTRAINT [DF_FaresSetup_ComenziFaraTVA] DEFAULT ((1)) NOT NULL,
    [AdresaLivrare1]                 VARCHAR (250)   NULL,
    [AdresaLivrare2]                 VARCHAR (250)   NULL,
    [AdresaLivrare3]                 VARCHAR (250)   NULL,
    [AfiseazaProprietarDocument]     BIT             CONSTRAINT [DF_FaresSetup_AfiseazaProprietarDocument] DEFAULT ((0)) NOT NULL,
    [FaraCodArticol]                 BIT             CONSTRAINT [DF_FaresSetup_FaraCodArticol] DEFAULT ((0)) NOT NULL,
    [FolosesteVarinata]              BIT             CONSTRAINT [DF_FaresSetup_FolosesteVarinata] DEFAULT ((1)) NOT NULL,
    [FolosesteTermenLivrare]         BIT             CONSTRAINT [DF_FaresSetup_FolosesteTermenLivrare] DEFAULT ((1)) NOT NULL,
    [UtilizeazaDepartament]          BIT             CONSTRAINT [DF_FaresSetup_UtilizeazaDepartament] DEFAULT ((1)) NOT NULL,
    [CotaTVADetaliuDocument]         BIT             CONSTRAINT [DF_FaresSetup_CotaTVADetaliuDocument] DEFAULT ((0)) NOT NULL,
    [RegimFiscalDetaliu]             BIT             CONSTRAINT [DF_FaresSetup_RegimFiscalDetaliu] DEFAULT ((0)) NOT NULL,
    [IDSeriePlati]                   VARCHAR (20)    CONSTRAINT [DF_FaresSetup_IDSeriePlati] DEFAULT ('') NOT NULL,
    [FolosesteValoareCuAdaos]        BIT             CONSTRAINT [DF_FaresSetup_FolosesteValoareCuAdaos] DEFAULT ((0)) NOT NULL,
    [SalveazaCuUrmatorulNumar]       BIT             CONSTRAINT [DF_FaresSetup_SalveazaCuUrmatorulNumar] DEFAULT ((1)) NOT NULL,
    [SalvareCuAdaugare]              BIT             CONSTRAINT [DF_FaresSetup_SalvareCuAdaugare] DEFAULT ((0)) NOT NULL,
    [FolosesteObservatii]            BIT             CONSTRAINT [DF_FaresSetup_FolosesteObservatii] DEFAULT ((1)) NOT NULL,
    [CaleD394]                       VARCHAR (250)   NULL,
    [AfiseazaDoarDocumenteleCurente] BIT             CONSTRAINT [DF_FaresSetup_AfiseazaDoarDocumenteleCurente] DEFAULT ((0)) NOT NULL,
    [ContVenitArticolImplicit]       [dbo].[TipCont] NULL,
    [AfiseazaSemnaturiTiparire]      BIT             CONSTRAINT [DF_FaresSetup_AfiseazaSemnaturiTiparire] DEFAULT ((1)) NOT NULL,
    [IDSerieBC]                      VARCHAR (20)    DEFAULT ('') NOT NULL,
    [IDSerieBF]                      VARCHAR (20)    DEFAULT ('') NOT NULL,
    [GestiuneaStocurilor]            BIT             DEFAULT ((1)) NOT NULL,
    [Valuta]                         BIT             DEFAULT ((1)) NOT NULL,
    [Bugetara]                       BIT             DEFAULT ((0)) NOT NULL,
    [JurnalImplicit]                 INT             DEFAULT ((0)) NULL,
    [ArtAlImplicit]                  VARCHAR (40)    NULL,
    [ValutaImplicita]                SMALLINT        DEFAULT ((0)) NOT NULL,
    [FolosesteTVAArticol]            BIT             DEFAULT ((0)) NULL,
    [FolosesteContract]              BIT             DEFAULT ((0)) NOT NULL,
    [Productie]                      BIT             DEFAULT ((0)) NOT NULL,
    [IDBancaImplicita]               SMALLINT        DEFAULT ((0)) NOT NULL,
    [ImplementareAmbalaje]           BIT             DEFAULT ((0)) NOT NULL,
    [AreDocGestStoc]                 BIT             DEFAULT ((1)) NOT NULL,
    [IDSerieAE]                      NVARCHAR (20)   NULL,
    [AvizExpeditieCuTVA]             BIT             DEFAULT ((0)) NOT NULL,
    [IDSerieFACT]                    NVARCHAR (20)   NULL,
    [IDSerieCHIT]                    NVARCHAR (20)   NULL,
    [ComandaFaraPreturi]             BIT             DEFAULT ((0)) NOT NULL,
    [ProdusePePartener]              BIT             DEFAULT ((0)) NOT NULL,
    [DenumireNumeric1]               VARCHAR (50)    DEFAULT ('Lungime') NOT NULL,
    [DenumireNumeric2]               VARCHAR (50)    DEFAULT ('Latime') NOT NULL,
    [DenumireNumeric3]               VARCHAR (50)    DEFAULT ('Inaltime') NOT NULL,
    [ZileScadentaClient]             INT             DEFAULT ((15)) NOT NULL,
    [ZileScadentaFurnizor]           INT             DEFAULT ((15)) NOT NULL,
    [TVAIncasareImplicit]            BIT             DEFAULT ((1)) NOT NULL,
    [PermiteTVALaIncasare]           BIT             DEFAULT ((1)) NOT NULL,
    [GestiuneCantitativa]            BIT             DEFAULT ((0)) NOT NULL,
    [PermitePretZero]                BIT             DEFAULT ((0)) NOT NULL,
    [FolosesteCPV]                   BIT             DEFAULT ((0)) NOT NULL,
    [DataReceptieEgalaDataFactura]   BIT             DEFAULT ((0)) NOT NULL,
    [FolosesteDataExtras]            BIT             DEFAULT ((0)) NOT NULL,
    CONSTRAINT [PK_FaresSetup] PRIMARY KEY CLUSTERED ([PrimaryKey] ASC, [CodUnitate] ASC),
    CONSTRAINT [FK_FaresSetul_Valuta] FOREIGN KEY ([ValutaImplicita]) REFERENCES [dbo].[Valuta] ([CodValuta]),
    CONSTRAINT [FK_FaresSetup_BancaImplicita] FOREIGN KEY ([IDBancaImplicita]) REFERENCES [dbo].[Banci] ([IdBanca]),
    CONSTRAINT [FK_FaresSetup_Jurnale] FOREIGN KEY ([JurnalImplicit]) REFERENCES [dbo].[Jurnale] ([IDJurnal]),
    CONSTRAINT [FK_FaresSetup_SeriiNumerice_Aviz_Expeditie] FOREIGN KEY ([IDSerieAE], [CodUnitate]) REFERENCES [dbo].[SeriiNumerice] ([IdSerie], [CodUnitate]),
    CONSTRAINT [FK_FaresSetup_SeriiNumerice_Chitanta] FOREIGN KEY ([IDSerieCHIT], [CodUnitate]) REFERENCES [dbo].[SeriiNumerice] ([IdSerie], [CodUnitate]),
    CONSTRAINT [FK_FaresSetup_SeriiNumerice_Factura] FOREIGN KEY ([IDSerieFACT], [CodUnitate]) REFERENCES [dbo].[SeriiNumerice] ([IdSerie], [CodUnitate]),
    CONSTRAINT [FK_FaresSetup_Unitati] FOREIGN KEY ([CodUnitate]) REFERENCES [dbo].[Unitati] ([CodUnitate])
);

